<!--
* description: 审核弹窗
* author:wangjuan
* createdDate:
-->
<template>
  <section class="editDialog">
    <el-dialog
      v-dialogDrag
      :title="titleName"
      :visible="popupsVisible"
      :append-to-body="true"
      width="50%"
      :close-on-click-modal="false"
      @close="closeEdit"
    >
      <dialogHeader
        slot="title"
        :title="titleName"
        :style-type="$store.state.app.dialogType"
      />
      <div class="app-container app-container-table">
        <one-table-template
          ref="multipleTable"
          :dynamic-components="tableComponents"
          :dynamic-api-config="apiConfig"
          :dynamic-form-fields="formField"
        />
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button
          v-for="comp in tableButtons"
          :key="comp.compKey"
          :type="comp.type"
          :icon="comp.icon"
          :fixed="true"
          @click="comp.clickEvent"
        >{{ comp.text }}</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>

import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import { formMixins } from '@/components/mixins/formMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import api from '@/api/subsidyManage'

export default {
  components: {
    OneTableTemplate,
    dialogHeader: () => import('@/components/dialogHeader')
  },

  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins, formMixins],

  props: {
    // 弹出是否显示
    popupsVisible: { type: Boolean, default: false },
    dataForForm: {
      type: Object,
      default: () => {}
    },
    popupsState: { type: String, default: '' }
  },

  data() {
    const viewPageCode = 'save-edit'
    return {
      titleName: '确认保存',
      // 保存API配置对象
      // apiConfig: orgApis.mdmOrgInfoMutationSupplierSave,

      // 动态组件-按钮
      tableButtons: [
        {
          compKey: 'btnKey1',
          type: 'primary',
          size: 'small',
          icon: 'iconfont  icon-confirm',
          clickEvent: () => this.save(),
          text: this.$t('sys.button.confirm'),
          position: 'right'
        },
        {
          compKey: 'btnKey2',
          type: '',
          size: 'small',
          icon: 'iconfont  icon-cancel',
          clickEvent: () => this.closeEdit(),
          text: this.$t('sys.button.cancel') // 取消
        }
      ],

      // 动态组件-查询条件
      tableComponents: [
        {
          compKey: 'compKey1',
          labelName: '驳回原因:',
          codeField: 'logContent',
          validrule: { noRequire: true },
          component: () => import('@/components/org/commonInput/textareaInput'),
          type: 'textarea',
          isMust: true,
          clearCode: true,
          isRequire: true,
          span: 24

        }
      ],
      // 表单数据（无需赋值，由混入对象赋值）
      formField: this.$utils.getFormField(this, {
        logContent: ''
      }, this.$ConfigCache.CacheConfig.cacheData[viewPageCode])
    }
  },
  methods: {
    // 关闭弹窗
    closeEdit(type) {
    // 关闭弹窗
      this.$emit('closeInEdit', type)
    },

    // 保存
    save() {
      this.$requestAPI({
        apiUrl: api.allrejectSubsidy.APIUrl,
        variables: { updateControlId: this.dataForForm.updateControlId, subsidyId: this.dataForForm.subsidyId, logContent: this.formField.logContent }
      }).then(res => {
        this.$message(res.msg)
        if (res.result === '1') {
          this.$emit('queryTableon')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.promptSpan{
  position: absolute;
  bottom: 26px;
  right: 335px;
  color: #e70020;
}
/deep/.filter-params .el-col{
  margin-bottom: 15px;
  }

</style>
